import java.util.Scanner;

public class Main1290{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String n=sc.nextLine();
        int x=0;
        for (int i=0;i<n.length();i++){
           x=x*8+(n.charAt(i)-'0');
        }
         System.out.println(x);
    }
}